/**
 * 询价.COM v1.0.0
 * http://xun-jia.com/
 *
 * Copyright (c) 2009 
 * 四川漾天空网络科技有限公司
 * 成都市天府软件园A3栋2楼
 *
 */
package com.xunjia.setup.action;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.Action;
import com.xunjia.action.XunJiaActionSupport;
import com.xunjia.exception.XunjiaException;

/**
 * @author Mark
 * 
 * @Email Mark_yang@xun-jia.com
 * 
 * @Date 2009-4-10 下午12:35:54
 * 
 */
public class AccountSetupAction extends XunJiaActionSupport {

	// 日誌
	private static final Logger logger = Logger.getLogger(AccountSetupAction.class);
	// 企業用戶操作DAO
	//private ManagerInfoDao managerInfoDao;
	private static final long serialVersionUID = -5333936020993678147L;
	/** 添加子账号 */
	// 帳戶名
	private String accountname;
	// 密碼
	private String pwd;
	// 是否可以查看報表
	private String reportable;
	// 是否可以購買廣告
	private String buyable;
	// 是否可以使用錢包
	private String walletable;
	/** 修改子账号密码 */
	// 新密码
	private String newpass;
	// 再次输入新密码
	private String newpassagain;
	/** 子帳戶管理 */
	//private List<ManagerInfo> allSubAccounts;

	/**
	 * 獲取所有子帳戶(子帳戶管理)
	 * 
	 * @return
	 * @throws Exception
	 */
	public String getAllSubAccount() throws Exception {
		/*try {
			allSubAccounts = new ArrayList<ManagerInfo>();
			Iterator<ManagerInfo> result = managerInfoDao.getEnterpriseAllManagerByEntId(Long.parseLong(belongsCompanyID));
			if (result != null) {
				while (result.hasNext()) {
					allSubAccounts.add(result.next());
				}
			}
		} catch (XunjiaException e) {
			logger.info(e.getMessage());
		}*/
		return Action.SUCCESS;
	}

	/**
	 * 刪除子帳號
	 * 
	 * @return
	 * @throws Exception
	 */
	public String deleteSubAccount() throws Exception {
		/*try {
			//managerInfoDao.deleteChildManager(accountname);
			addActionMessage(getText("sub.account.delete.success"));
		} catch (XunjiaException e) {
			logger.info(e.getMessage());
			addActionMessage(getText("sub.account.delete.failure"));
		}*/
		return Action.SUCCESS;
	}

	/**
	 * 添加一個子帳戶
	 * 
	 * @return
	 * @throws Exception
	 */
	public String addSubAccount() throws Exception {
		logger.info("addSubAccoutn");
		addActionMessage(getText("sub.account.add.success"));
		return Action.SUCCESS;
	}

	/**
	 * 修改子账号密码
	 * 
	 * @return
	 * @throws Exception
	 */
	public String updateSubAccountPassword() throws Exception {
		logger.info(accountname);
		logger.info(newpass);
		logger.info(newpassagain);
		addActionMessage(getText("sub.account.password.update.success"));
		return Action.SUCCESS;
	}

	/**
	 * @return the accountname
	 */
	public String getAccountname() {
		return accountname;
	}

	/**
	 * @param accountname
	 *            the accountname to set
	 */
	public void setAccountname(String accountname) {
		this.accountname = accountname;
	}

	/**
	 * @return the pwd
	 */
	public String getPwd() {
		return pwd;
	}

	/**
	 * @param pwd
	 *            the pwd to set
	 */
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	/**
	 * @return the reportable
	 */
	public String getReportable() {
		return reportable;
	}

	/**
	 * @param reportable
	 *            the reportable to set
	 */
	public void setReportable(String reportable) {
		this.reportable = reportable;
	}

	/**
	 * @return the buyable
	 */
	public String getBuyable() {
		return buyable;
	}

	/**
	 * @param buyable
	 *            the buyable to set
	 */
	public void setBuyable(String buyable) {
		this.buyable = buyable;
	}

	/**
	 * @return the walletable
	 */
	public String getWalletable() {
		return walletable;
	}

	/**
	 * @param walletable
	 *            the walletable to set
	 */
	public void setWalletable(String walletable) {
		this.walletable = walletable;
	}


	/**
	 * @return the newpass
	 */
	public String getNewpass() {
		return newpass;
	}

	/**
	 * @param newpass
	 *            the newpass to set
	 */
	public void setNewpass(String newpass) {
		this.newpass = newpass;
	}

	/**
	 * @return the newpassagain
	 */
	public String getNewpassagain() {
		return newpassagain;
	}

	/**
	 * @param newpassagain
	 *            the newpassagain to set
	 */
	public void setNewpassagain(String newpassagain) {
		this.newpassagain = newpassagain;
	}
}
